﻿uniform sampler2D SourceMap;
uniform sampler2D FrameMap;
uniform sampler2D DistortMap;

uniform vec4 FrameCol;
uniform float DistortStrength;

void main(){

	vec3 fc = texture2D( FrameMap,gl_TexCoord[0].st ).rgb;
	vec3 norm = texture2D( DistortMap,gl_TexCoord[0].st ).rgb;
	norm = -1.0+norm*2.0;
	vec2 uv = gl_TexCoord[1].st;
	uv.y = 1.0-uv.y;
	vec3 fb = texture2D( SourceMap,uv + norm * DistortStrength).rgb;

	gl_FragColor.rgb = (fc*FrameCol.rgb*FrameCol.a)+(fb*(1.0-FrameCol.a));
	gl_FragColor.a = 1.0;

}